/**
 * 作者：陈文斌 on 2019/1/13.
 * 邮箱：chen_wennbin@163.com
 * 版本：v1.0
 */

import 'package:flutter/material.dart';
import 'package:crm/constant/constant.dart';
import 'package:crm/model/ClientManager/client_info_model.dart';
import 'package:crm/view/Tile/list_tile_normal.dart';
import 'package:crm/component/ClientManager/ClientInfo/client_info_section.dart';
import 'package:crm/component/ClientManager/ClientInfo/client_info_tile_section.dart';
import 'package:crm/component/ClientManager/ClientInfo/client_material_tile_section.dart';
import 'package:crm/view/AppBar/custom_app_bar.dart';

const String Title = '潜在客户资料';

class PotentialClientInfoPage extends StatefulWidget {
  final ClientInfoModel clientInfo;

  @override
  PotentialClientInfoPage({
    Key key,
    @required this.clientInfo,
  }) : super(key: key);

  State<StatefulWidget> createState() {
    return _PotentialClientInfoPageState();
  }
}

class _PotentialClientInfoPageState extends State<PotentialClientInfoPage> {
  final List<String> titles = ['行业属性', '行业类别', '预售金额', '预成交日', '预成几率'];

  Map<String, String> contents;

  @override
  void initState() {
    contents = {
      '行业属性': widget.clientInfo.industryAttributes ?? '',
      '行业类别': widget.clientInfo.industryClassification ?? '',
      '预售金额': widget.clientInfo.salesMoney ?? '0',
      '预成交日': widget.clientInfo.exdealDate ?? '',
      '预成几率': '${widget.clientInfo.exdealProbability ?? 0}%'
    };
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(
        title: Title,
      ),
      body: ListView(
        children: <Widget>[
          ClientInfoSection(
            clientInfo: widget.clientInfo,
          ),
          Padding(padding: EdgeInsets.only(top: 1)),
          ClientInfoTileSection(
            titles: titles,
            contents: contents,
          ),
          Divider(
            height: 1,
            color: AppColors.LineColor,
          ),
          ListTileNormal(
            title: Row(
              children: <Widget>[
                Text(
                  '销售阶段',
                  style: TextStyle(
                    color: AppColors.DetailTextColor,
                    fontSize: AppFontSizes.Font14,
                    fontFamily: AppFontFamilies.PingFangSC,
                    fontWeight: FontWeight.w500,
                  ),
                ),
                Padding(padding: EdgeInsets.only(right: 20)),
                Text(
                  widget.clientInfo.salesStage ?? '',
                  style: TextStyle(
                    color: AppColors.PlaceholderTextColor,
                    fontSize: AppFontSizes.Font14,
                    fontFamily: AppFontFamilies.PingFangSC,
                    fontWeight: FontWeight.w500,
                  ),
                ),
              ],
            ),
          ),
          Padding(padding: EdgeInsets.only(top: 10)),
          ClientMaterialTileSection(
            customerType: widget.clientInfo.customerType,
          ),
        ],
      ),
    );
  }
}
